www.gusucode.com > XerCMS 携云PHP企业建站程序 v2015PHP源码程序 > XerCMS 携云PHP企业建站程序 v2015/XerCMS_v20150724/XerCMS_v20150724/Assets/Js/XerCMS.js

    var XerCMS = {
     debug  : true,
	embed  : function() {return window[arguments[0]] ? window[arguments[0]] : document[arguments[0]];},
     upload : {
	     show  : function(container,id) {
		     var d = 'div'.element();
			d.cls('upload-show');
			d.html('<img src="' + XERCMS_ROOT + 'Assets/images/loading!150x150.gif" id="upload_' + id + '" >');
			$(container).child(d);
		},
	     openHandler   : function (handler,id) {
			XerCMS.debug && console.log('[' + handler +  '] openHandler:' + id);
			if (typeof(upload[handler]) != 'undefined') {
			     upload[handler]('open',id);
			}		
		},
          selectHandler : function(handler,id,name,size) {
               //alert(id + '|' + name + '|' + size);
			//alert(id);
			XerCMS.debug && console.log('[' + handler +  '] selectHandler:' + id);
			if (typeof(upload[handler]) != 'undefined') {
			     upload[handler]('select',id,name,size);
			}
			
          },
          ioErrorHandler : function(handler,id) {
               //alert(id);
			XerCMS.debug && 'ioError'.tips();//console.log('[' + handler +  '] ioErrorHandler:' + id);
			if (typeof(upload[handler]) != 'undefined') {
			     upload[handler]('io',id);			
			}
			
			
          },
		httpStatusHandler : function(handler,id,status) {
               //alert(id);
			XerCMS.debug && ('httpStatus : ' + status).tips();//console.log('[' + handler +  '] httpStatus:' + status);
			if(status != 200) {
				if (typeof(upload[handler]) != 'undefined') {
			          upload[handler]('httpError',id,status);				
				}				
			}// else 
			
          },
          returnHandler : function(handler,id,data) {
               //alert(id);
			//alert(data);
			XerCMS.debug && console.log('[' + handler +  '] returnHandler:' + data);
			var JsonData = data.json();
               if (typeof(JsonData.XerCMS) != 'undefined' && JsonData.XerCMS.length > 0 && JsonData.XerCMS != 'Success') {
			     JsonData.XerCMS.tips();
			} else {
			     if (typeof(upload[handler]) != 'undefined') {
			          upload[handler]('return',id,JsonData.data);	
				}
			}			
          },
          progressHandler : function(handler,id,bytesLoaded,bytesTotal) {
               //alert(id);
			//console.log('progressHandler:' + id);
			XerCMS.debug && console.log('[' + handler +  '] progressHandler:' + bytesLoaded + '/' + bytesTotal);
			if (typeof(upload[handler]) != 'undefined') {
			    upload[handler]('progress',id,bytesLoaded,bytesTotal);
			}
			
          },
		securityErrorHandler : function(handler,id) {
               //alert(id);
			XerCMS.debug && 'securityError'.tips();//console.log('[' + handler +  '] securityError:' + id);
			if (typeof(upload[handler]) != 'undefined') {
			     //XerCMS.debug && console.log('securityError:' + id);
			     upload[handler]('security',id);
			}
			
			
          },
          completeHandler : function(handler,id) {
               //alert(id);
			XerCMS.debug && console.log('[' + handler +  '] completeHandler:' + id);
			if (typeof(upload[handler]) != 'undefined') {
			    upload[handler]('complete',id);
			}			
          }
		
     },
	cache : new Array()
};

function addfavorite() { 
     try { 
          window.external.addfavorite(document.location.href ,document.title); 
     } catch (e) { 
          try  { 
               window.sidebar.addPanel(document.title,document.location.href ); 
          } catch (e) { 
               ("加入收藏失败,请使用ctrl+d进行添加。").tips(); 
          } 
     } 
} 

function sethome(obj) { 
     try { 
          obj.style.behavior='url(#default#homepage)';
          obj.setHomePage(document.location.href); 
     } catch(e) { 
          if(window.netscape) { 
               try { 
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
               } catch (e) { 
                    ("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。").tips(); 
               } 
               var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
               prefs.setCharPref('browser.startup.homepage',document.location.href); 
          } 
     } 
}


function moveTofav() {
     var title = arguments[0] == undefined ? document.title : arguments[0];
     var url = arguments[1] == undefined ? location.href : arguments[1]; 
     var f = document.createElement('form');
     f.action = XERCMS_ROOT + 'index.php?m=member&a=addfav';
     f.method = 'post';
     var i = document.createElement('input');
     i.name = 'title';i.value = title;
     f.appendChild(i);
     i = document.createElement('input');
     i.name = 'url';i.value = url;
     f.appendChild(i);
     document.getElementsByTagName('body')[0].appendChild(f);
     f.submit();
}

function gopage(id) {
     var maxPage = parseInt(U('#' + id).attr('maxpage'));
     var Page = parseInt(U('#' + id).val());var tipStr = '';
     if(isNaN(Page)) {
          Page = 1;      
     }
     if(Page >= maxPage) {
          tipStr = '当前页数已是最后一页!';
          tipStr.tips();
     } else if (Page < 1) {
          location.href = U('#' + id).attr('url').replace('{page}',1);
     } else location.href = U('#' + id).attr('url').replace('{page}',Page);
}

function vote(vid,oid)
{
     var ajax = $.ajax();
     var url = XERCMS_ROOT + 'index.php?m=extends&a=vote&vid=' + vid + '&oid=' + oid;
     ajax.onreadystatechange = function() {
	     if(ajax.readyState == 4) {
               if(ajax.status == 200) {
                    var ret = ajax.responseText.json();
                    if(typeof(ret.XerCMS)){ret.XerCMS.tips()} else {'数据错误'.tips();}            
               } else '网络错误或繁忙,请稍后操作。'.tips();
          }
     }
     ajax.open('GET',url,true);
     ajax.send(null);
}